package org.example.gametalk.gameTalkUtils;

import lombok.Data;
import org.example.gametalk.Entity.Enum.ResponseEnum;

@Data
public class Response<T> {
    private Integer code;
    private String message;
    private T data;

    public Response(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Response(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Response<Object> success() {
        return new Response<Object>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMessage());
    }

    public static Response<Object> success(String msg) {
        return new Response<Object>(ResponseEnum.SUCCESS.getCode(), msg);
    }

    public static Response<Object> fail() {
        return new Response<Object>(ResponseEnum.FAIL.getCode(), ResponseEnum.FAIL.getMessage());
    }
    public static Response<Object> fail(String msg) {
        return new Response<Object>(ResponseEnum.FAIL.getCode(), msg);
    }
    public  Response<T>  setData(T data) {
        this.data = data;
        return this;
    }

}
